<template>
	<cl-select-table
		v-model="value"
		:title="t('选择档案信息')"
		:service="service.userProfile.profile"
		:columns="columns"
		:multiple="multiple"
		:dict="{ text: 'name' }"
		pickerType="text"
	/>
</template>

<script setup lang="ts">
defineOptions({
	name: "userProfile-profile-select",
});

import { useCool } from "/@/cool";
import { useI18n } from "vue-i18n";
import { CrudProps } from "/#/crud";
import { reactive, ref, useModel } from "vue";

const props = defineProps({
	...CrudProps,
	modelValue: null,
	multiple: Boolean,
});

const { service } = useCool();
const { t } = useI18n();

const value = useModel(props, "modelValue");

// 选项
const options = reactive({
	gender: [
		{ label: t("未知"), value: 0 },
		{ label: t("男"), value: 1 },
		{ label: t("女"), value: 2 },
	],
	maritalStatus: [
		{ label: t("未婚"), value: 0 },
		{ label: t("已婚"), value: 1 },
		{ label: t("离异"), value: 2 },
	],
});

const columns = ref([
	{ label: t("昵称"), prop: "userName", minWidth: 140 },
	{ label: t("姓名"), prop: "name", minWidth: 140 },
	{ label: t("性别"), prop: "gender", minWidth: 120, dict: options.gender },
	{
		label: t("出生日期"),
		prop: "birthDate",
		minWidth: 140,
		sortable: "custom",
		component: { name: "cl-date-text", props: { format: "YYYY-MM-DD" } },
	},
	{ label: t("联系方式"), prop: "contact", minWidth: 140 },
	{ label: t("联系地址"), prop: "address", minWidth: 120 },
	{ label: t("紧急联系人"), prop: "emergencyContact", minWidth: 140 },
	{ label: t("身份证号"), prop: "idCard", minWidth: 140 },
	{ label: t("电子邮箱"), prop: "email", minWidth: 140 },
	{
		label: t("婚姻状况"),
		prop: "maritalStatus",
		minWidth: 120,
		dict: options.maritalStatus,
	},
	{ label: t("工作单位"), prop: "workUnit", minWidth: 140 },
	{
		label: t("个人简介"),
		prop: "summary",
		showOverflowTooltip: true,
		minWidth: 200,
	},
	{
		label: t("备注"),
		prop: "remark",
		showOverflowTooltip: true,
		minWidth: 200,
	},
]);
</script>
